package com.tian.authen.api.feign;


import com.tian.authen.api.feign.request.OauthAccessTokenId;
import com.tian.authen.api.feign.response.OauthAccessTokenResponse;
import com.tian.common.domain.DomainConstant;
import com.tian.common.result.BaseResult;
import com.tian.common.result.Result;
import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


/**
 * <pre>
 *  认证服务feign接口
 * </pre>
 * @author zhump
 */
@FeignClient(name = DomainConstant.ZHUMP_AUTHEN)
public interface AuthenFeign {


    @RequestMapping(value = "/accessToken/getTokenId",method = RequestMethod.POST)
    @CircuitBreaker(name = DomainConstant.ZHUMP_AUTHEN,fallbackMethod = "getTokenHystrix")
    public BaseResult<OauthAccessTokenResponse> getToken(@RequestBody OauthAccessTokenId requestToken);

    /**
     * <pre>
     *     获取token熔断
     * </pre>

     */
    default BaseResult getTokenHystrix(Throwable throwable){
        return Result.error("authen服务异常,获取token失败。。。");
    }
}
